package service

import (
	"RocFamilySystem/internal/repository"
	"RocFamilySystem/models"
)

type WorkTravelPayService struct {
	WorkTravelPayRepository *repository.WorkTravelPayRepository
}

// 初始化
func init() {
	registerContainer["WorkTravelPayService"] = &WorkTravelPayService{}
}

// SetRepository 设置持久层
func (service *WorkTravelPayService) SetRepository(workTravelPayRepository *repository.WorkTravelPayRepository) {
	service.WorkTravelPayRepository = workTravelPayRepository
}

// AddWorkTravelPay 添加工作出差支付
func (service *WorkTravelPayService) AddWorkTravelPay(workTravelPay *models.WorkTravelPay, loginUserId int) {
	workTravelPay.CreateBy = &loginUserId
	service.WorkTravelPayRepository.InsertWorkTravelPay(workTravelPay)
}

// RemoveWorkTravelPay 删除工作出差支付
func (service *WorkTravelPayService) RemoveWorkTravelPay(workTravelPayId int, loginUserId int) {
	service.WorkTravelPayRepository.DeleteWorkTravelPay(workTravelPayId, loginUserId)
}

// ModifyWorkTravelPay 修改工作出差支付
func (service *WorkTravelPayService) ModifyWorkTravelPay(workTravelPay *models.WorkTravelPay, loginUserId int) {
	service.WorkTravelPayRepository.UpdateWorkTravelPay(workTravelPay, loginUserId)
}

// QueryWorkTravelPay 查询工作出差支付
func (service *WorkTravelPayService) QueryWorkTravelPay(workTravelPay *models.WorkTravelPay, pageNum, pageSize int, loginUserId int) PageInfo {
	tables, total := service.WorkTravelPayRepository.SelectWorkTravelPay(workTravelPay, pageNum, pageSize, loginUserId)
	return toPageInfo(pageNum, pageSize, total, tables)
}

// QueryWorkTravelPayById 通过ID查询工作出差支付
func (service *WorkTravelPayService) QueryWorkTravelPayById(id int, loginUserId int) models.WorkTravelPay {
	return service.WorkTravelPayRepository.SelectWorkTravelPayById(id, loginUserId)
}

// RemoveWorkTravelPayBatch 批量删除工作出差支付
func (service *WorkTravelPayService) RemoveWorkTravelPayBatch(ids []string, loginUserId int) {
	service.WorkTravelPayRepository.DeleteWorkTravelPayBatch(ids, loginUserId)
}
